/**
 * 功能描述 列表触发事件
 */
define(function (require, exports, module) {
	var Dialog = require("dialog");
	var aw = require("ajaxwrapper");
	
    module.exports = {
    	saveCharge : function(widget){
    		var sucList = widget.get("editgrid").getData();
    		for(var i = 0; i < sucList.length; i++){
    			if(sucList[i].operator != null && typeof sucList[i].operator != "string"){
    				sucList[i].operator = sucList[i].operator.pkUser;
    			}
    			if(sucList[i].chargeDate != null){
    				sucList[i].chargeDate = moment(sucList[i].chargeDate).format("x");
    			}
    			sucList[i].signUpRegister.personalInfo.sex = sucList[i].signUpRegister.personalInfo.sex.key;
    		}
    		var data = {
    			sucList	: sucList
    		};
    		aw.saveOrUpdate("api/signupcharge/savecharge", aw.customParam(data), function(datas){
    			widget.hide([".J-form", ".J-editgrid", ".J-detailgrid"]).show(".J-grid");
				widget.get("subnav").hide(["save", "cancel"]).show(["startDate", "destination", "status", "servicePoint"]);
    			widget.get("grid").refresh();
    			Dialog.tip("保存成功！");
    		})
    	}	
    };
});
